package com.gxuwz.controller;


import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.gxuwz.entity.Material;
import com.gxuwz.service.IMaterialService;

/**
 * <p>
 *  物料前端控制器
 * </p>
 *
 * @author 刘玉霜
 * @since 2017-10-27
 */
@Controller
@RequestMapping("/material")
public class MaterialController implements ICurdController<Material>{
	
	private static Logger log = Logger.getLogger(UserController.class);
	
	private Map<String,Object> json = null;
	
	@Autowired
	private IMaterialService materialService;
	
	public MaterialController(){
		json = new HashMap<String,Object>();
	}

	@Override
	public String openAddView() {
		return "material/add-material";
	}

	@Override
	public Map<String, Object> add(Material t, Model model) {
		log.info("********** execute save material method **********");
		if(null == t){
			json.put("code", -1);
			return json;
		}	
		json.put("code", materialService.save(t));
		return json;
	}

	@Override
	public String list(Model model,Material m) {
		return null;
	}

	@Override
	public Map<String, Object> delete(Material t) {
		return null;
	}

	@Override
	public String openUpdateView(String id, Model model) {
		return null;
	}

	@Override
	public Map<String, Object> update(Material t) {
		return null;
	}
	
}
